<style>
    @media screen and (max-width: 600px) {
	.page-body,.page-tab-content,.layui-colla-content{padding:0px;}
	.layui-table td, .layui-table th{padding:5px 2px; text-align:center;}
	.fixed-bar .layui-input {width:80px;}
}
</style>
<form class="layui-form" action="{:url()}" method="post" id="editForm">
    
    <div class="layui-form-item">
    {:FormExt::setInline()}
    {:FormExt::showText('订单ID', $oInfo['id'])}
    {:FormExt::showText('订单号', $oInfo['client_ordernum'])}
	{if env('env_site') == 'riwei' }
		{:FormExt::input('客户单号', 'ext_id', '', '请输入客户单号', '', 'lay-verify=""')}
	{/if}
    {:FormExt::showText('SKU', $oInfo['sku'])}
    {:FormExt::input('款式颜色', 'dress_color', '', '请输入款式颜色', '', 'lay-verify=""')}
    {:FormExt::showText('加工费', $sInfo['cost'])}
    {:FormExt::showText('下单时间', date('Y-m-d H:i:s', $oInfo['create_time']))}
    {:FormExt::showText('出货时间', date('Y-m-d H:i:s', $oInfo['shipment_time']))}
    {:FormExt::showText('订单类型', config('mimo.order_otype')[$oInfo['o_type']])}
    
    {:FormExt::select('所属工厂', 'factory_id', '', $factoryKV, '', '')}
    {:FormExt::select('产品分组', 'group_id', '', $groupKV, '', '')}
    {:FormExt::radio('是否外发', 'outgo_status', '', ['0' => '否', '2' => '是'], '', '')}
    {:FormExt::select('外发工厂', 'factory_outgo_id', '', $factoryOutgoKV, '', '')}
    {:FormExt::input('外发价格', 'outgo_price', '', '请输入外发价格', '', 'lay-verify="mimonumber"')}
    {:FormExt::datetime('外发时间', 'outgo_time', '', '', '请选择外发时间', '', 'lay-verify=""')}
	{:FormExt::showText('外发完成时间', date('Y-m-d H:i:s', $oInfo['outgo_over_time']))}
<!--    {:FormExt::datetime('外发完成时间', 'outgo_over_time', '', '', '请选择外发完成时间', '', 'readonly lay-verify=""')}-->
    {:FormExt::datetime('采购完成时间', 'caigou_over_time', '', '', '请选择采购完成时间', '', 'lay-verify=""')}
    {:FormExt::datetime('裁床完成时间', 'caichuang_over_time', '', '', '请选择裁床完成时间', '', 'lay-verify=""')}
		{:FormExt::showText('车间完成时间', date('Y-m-d H:i:s', $oInfo['chejian_over_time']))}
		{:FormExt::showText('尾部完成时间', date('Y-m-d H:i:s', $oInfo['tail_over_time']))}
		{:FormExt::showText('实际出货时间', date('Y-m-d H:i:s', $oInfo['real_shipment_time']))}
		{:FormExt::showText('订单完成时间', date('Y-m-d H:i:s', $oInfo['over_time']))}
<!--		{:FormExt::datetime('车间完成时间', 'chejian_over_time', '', '', '请选择车间完成时间', '', 'lay-verify=""')}-->
<!--    {:FormExt::datetime('尾部完成时间', 'tail_over_time', '', '', '请选择尾部完成时间', '', 'lay-verify=""')}-->
<!--    {:FormExt::datetime('实际出货时间', 'real_shipment_time', '', '', '请选择实际出货时间', '', 'lay-verify=""')}-->
<!--    {:FormExt::datetime('订单完成时间', 'over_time', '', '', '请选择订单完成时间', '', 'lay-verify=""')}-->
    </div>
    {:FormExt::setInline(false)}
    {:FormExt::textarea('订单备注', 'remark', '', '', '请输入订单备注')}
    
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>尺码件数 </legend>
	</fieldset>
	<div class="layui-form material-list">
		<table class="layui-table">
			<thead>
				<tr>
					<th>尺码</th>
					<th>下单数</th>
					<th>裁床数</th>
					<th>车间数</th>
					<th>后整数</th>
					<th>出货数</th>
				</tr>
			</thead>
			<tbody>
				{foreach $osList as $os}
				<tr>
					<td>{$os['size_name']}</td>
					<td><input type="text" name="os_order_count[{$os['mid']}]" value="{$os['order_count']}" class="layui-input" lay-verify="required|mimonumber"></td>
					<td><input type="text" name="os_shicai_count[{$os['mid']}]" value="{$os['shicai_count']}" class="layui-input" lay-verify="required|mimonumber"></td>
					<td><input type="text" name="os_jiaohuo_count[{$os['mid']}]" value="{$os['jiaohuo_count']}" class="layui-input" lay-verify="required|mimonumber"></td>
					<td><input type="text" name="os_jiaohuo_tail_count[{$os['mid']}]" value="{$os['jiaohuo_tail_count']}" class="layui-input" lay-verify="required|mimonumber"></td>
					<td><input type="text" name="os_daohuo_count[{$os['mid']}]" value="{$os['daohuo_count']}" class="layui-input" lay-verify="required|mimonumber"></td>
				</tr>
				{/foreach}
			</tbody>
		</table>
	</div>
	
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>扎数信息 <a href="javascript:void(0)" class="layui-btn layui-btn-primary layui-btn-xs zhahao-add"><i class="layui-icon">&#xe654;</i></a> </legend>
	</fieldset>
	<div class="layui-form zhahao-list">
		<table class="layui-table">
			<thead>
				<tr>
					<th>扎号</th>
					<th>件数</th>
					<th>码数</th>
					<th>床号</th>
					<th>删除</th>
					<th>打菲</th>
				</tr>
			</thead>
			<tbody>
				{foreach $ouList as $ouKey=>$ouVal }
					<tr class="item-{$ouVal['zhahao']}">
						<td><input type="text" name="zhahao[]" value="{$ouVal['zhahao']}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
						<td><input type="text" name="jianshu[]" value="{$ouVal['jianshu']}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
						
						<td>
						<select class="" name="size_name[]">
							{foreach $sizeNameArr as $sv}
							<option value="{$sv}" {if ($sv == $ouVal['size_name'])}selected{/if} >{$sv}</option>
							{/foreach}
						</select>
						</td>
						<td><input type="text" name="chuanghao[]" value="{$ouVal['chuanghao']}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
						<td><a href="javascript:void(0)" class="layui-btn layui-btn-danger layui-btn-sm btn-del" refresh="false" callback="callbackDel">
							<i class="layui-icon">&#xe640;</i></td>						
						<td><a href="{:url('cutting/fecode')}?order_id={$orderId}&mid={$ouVal['mid']}" target="_blank" class="layui-btn layui-btn-primary layui-btn-sm" title="菲码打印"><i class="layui-icon">&#xe66d;</i></a></td>						
					</tr>
				{/foreach}
			</tbody>
		</table>
	</div>
	
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>材料 </legend>
	</fieldset>
	<div class="layui-form material-list">
		<table class="layui-table">
			<thead>
				<tr>
					<th>物料名称</th>
					<th>物料SKU</th>
					<th>型号</th>
					<th>色号</th>
					<th>颜色</th>
					<th>客户用量</th>
					<th>{:config("base.company_short_name")}用量</th>
					<th>客户单价</th>
					<th>单价</th>
					<th>客户布封</th>
				</tr>
			</thead>
			<tbody>
				{foreach $omList as $v}
				<tr>
					<td>{$v['mInfo']['name']}</td>
					<td>{$v['mInfo']['material_sku']}</td>
					<td>{$v['mInfo']['model']}</td>
					<td>{$v['mInfo']['colornum']}</td>
					<td>{$v['mInfo']['color']}</td>
					<td><input type="text" name="customer_dosage[{$v['mInfo']['id']}]" value="{$v['customer_dosage']}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
					<td><input type="text" name="material_dosage[{$v['mInfo']['id']}]" value="{$v['material_dosage']}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
					<td>{$v['customer_price']}</td>
					<td>{$v['mInfo']['price']}</td>
					<td>{$v['fabric_width']}</td>
				</tr>
				{/foreach}
			</tbody>
		</table>
	</div>
	
    <div class="pop-bottom-bar">
    	<input type="hidden" class="field-id" name="order_id">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">提交保存</button>
		<a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

{include file="system@block/layui" /}
    
<script>
    var formData = {:json_encode($oInfo)};
    var sizeNameArr = {:json_encode($sizeNameArr)};
    layui.use(['form', 'func', 'tool', 'layer', 'laydate'], function() {
        var $ = layui.jquery;
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        layui.func.assign(formData);
        
        form.render();
		var reg = /((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/;
        form.verify({
        	mimonumber: function(value, item){
        	    if (value=='') return '';
        	    if(! reg.test(value)){
        	    	return '只能填写数字';
        	    }
        	}
        });

        /* 绑定多个日期控件 */
        $('.layui-date').each(function(i) {
            var t = $(this), option = {
                elem: this,
                type: t.attr('laydate-type'),
                mark: {'{:$today}':''},
                trigger: 'click'
            };

            laydate.render(option);
        });
        
     	// 添加扎数
        $(document).on('click', '.zhahao-add',function(){
        	var html='<tr>';
        	html += '<td><input type="text" name="zhahao[]" value="" autocomplete="off" class="layui-input" lay-verify="required|number"></td>';
        	html += '<td><input type="text" name="jianshu[]" value="" autocomplete="off" class="layui-input" lay-verify="required|number"></td>';
        	html += '<td><select class="" name="size_name[]">';
			for(var i in sizeNameArr) {
				html += '<option value="'+sizeNameArr[i]+'">'+sizeNameArr[i]+'</option>';
			}
			html += '</select></td>';
        	html += '<td><input type="text" name="chuanghao[]" value="" autocomplete="off" class="layui-input" lay-verify="required|number"></td>';
        	html += '<td><a href="javascript:void(0)" class="layui-btn layui-btn-danger layui-btn-sm btn-del"><i class="layui-icon">&#xe640;</i></a></td>';
        	html += '<td></td>';
        	html += '<tr>';
        	$('.zhahao-list table tbody').append(html);
        	form.render();
		});
        //删除回调
        window.callbackDel = function(obj, res) {
			if(res.code == 1) {
				 var zhahao = res.data.zhahao;
				 $('.item-'+zhahao).remove();
			}
		};
        // 删除条目
        $(document).on('click', '.btn-del',function(){
			$(this).parents('tr').remove();
		});
    });
</script>